/*
 * @Date         : 2024-03-03 16:59:52
 * @LastEditTime : 2024-07-11 14:59:01
 * @description  :
 */
const TokenKey = "Admin-Token";

/**
 * 获取token
 */
export function getToken() {
  return sessionStorage.getItem(TokenKey);
}

/**
 * 设置token
 * @param {*} token
 */
export function setToken(token) {
  return sessionStorage.setItem(TokenKey, token);
}

/**
 * 删除token
 */
export function removeToken() {
  return sessionStorage.removeItem(TokenKey);
}

/**
 * 数据签名
 * @param {*} obj
 */
export function getSignature(obj) {
  let encrypt = {};
  if (obj) {
    encrypt = obj;
  }
  // 签名
  const signature = getEncrypt(encrypt, defaultSettings.appSecret);
  encrypt.signature = signature;
  return encrypt;
}

export function clearAllSession() {
  for (let i = sessionStorage.length - 1; i >= 0; i--) {
    const key = sessionStorage.key(i);
    if (key !== "ROLES") {
      sessionStorage.removeItem(key);
    }
  }
}
